/**
 * 
 */
package us.gaaoc.framework.webapp.backingbeans.agent;

import java.util.Map;

import javax.faces.component.UISelectItem;
import javax.faces.component.html.HtmlSelectOneListbox;
import javax.faces.model.SelectItem;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.transaction.annotation.Transactional;

import us.gaaoc.framework.webapp.backingbeans.BaseBackingBean;
import us.gaaoc.framework.webapp.backingbeans.caseTypes.OCSSCaseType;
import us.gaaoc.framework.webapp.backingbeans.profile.Links;

/**
 * @author Sukahda Tapshalkar
 * Mar 23, 2007
 *
 */
public class NewFiling extends BaseBackingBean{

	/**
	 * 
	 */
	private static final long serialVersionUID = 2915092325638696696L;

	/**
	 * Properties
	 */
	private static final Logger LOG = Logger.getLogger(NewFiling.class);
	
	private HtmlSelectOneListbox  ocssCaseTypeUI;
	
	

	/**
	 * Constructor
	 *
	 */
	public NewFiling() {
		
		this.ocssCaseTypeUI = new HtmlSelectOneListbox();
		OCSSCaseType ocssCaseType = new OCSSCaseType(this.getModelFacade());
		for (Links links : ocssCaseType.getMenu()) {
			SelectItem item = new SelectItem(links.getNavigationRule(), links.getText());
			UISelectItem uiItem = new UISelectItem();
			uiItem.setValue(item);

			this.ocssCaseTypeUI.getChildren().add(uiItem);
		}
	}
	/**
	 * @return the ocssCaseTypeUI
	 */
	public HtmlSelectOneListbox getOcssCaseTypeUI() {
		return ocssCaseTypeUI;
	}

	/**
	 * @param ocssCaseTypeUI the ocssCaseTypeUI to set
	 */
	public void setOcssCaseTypeUI(HtmlSelectOneListbox ocssCaseTypeUI) {
		this.ocssCaseTypeUI = ocssCaseTypeUI;
	}

	public String submitAction() {
		//String navigationString = "";
		String navigationString = "filingcategoryselected";
		// TODO Determine if there is a better way to pass the external case category selected to the
		// next page

		Map<String, Object> sessionMap = this.getFacesContext().getExternalContext().getSessionMap();
		
		/*
		if (this.getOcssCaseTypeUI().getValue().equals("establishment")) {    
			//navigationString = "establishment";
			sessionMap.put("externalCaseCategoryCode", 1); // Establishment
		} else if (this.getOcssCaseTypeUI().getValue().equals("contempt")) {
			//navigationString = "contempt";
			sessionMap.put("externalCaseCategoryCode", 2); // Contempt
		} else if (this.getOcssCaseTypeUI().getValue().equals("reviewOrModification")) {
			//navigationString = "revisionOrModification";
			sessionMap.put("externalCaseCategoryCode", 3); // Review/Modification
		} else if (this.getOcssCaseTypeUI().getValue().equals("motionToRedirect")) {
			//navigationString = "motionToRedirect";
			sessionMap.put("externalCaseCategoryCode", 4); // Motion to Redirect
		} else if (this.getOcssCaseTypeUI().getValue().equals("motionToTransfer")) {
			//navigationString = "motionToTransfer";
			sessionMap.put("externalCaseCategoryCode", 5); // Motion to Transfer
		} else if (this.getOcssCaseTypeUI().getValue().equals("registration")) {
			//navigationString = "registration";
			sessionMap.put("externalCaseCategoryCode", 6); // Registration
		}
		*/
		sessionMap.put("externalCaseCategoryCode",Integer.parseInt((String)this.getOcssCaseTypeUI().getValue()));
		return navigationString;
	}
	
	public String back() {		
		return "allFilingsPage";
	}
	
}
